package com.vim.modules.mall.controller;

import com.github.pagehelper.PageInfo;
import com.vim.common.base.BaseController;
import com.vim.modules.mall.model.base.Page;
import com.vim.modules.mall.model.mallMember.MallMember;
import com.vim.modules.mall.model.base.CommonPage;
import com.vim.modules.mall.model.base.MallResponseEntity;
import com.vim.modules.mall.service.MallMemberService;
import com.vim.modules.mall.service.remote.RemoteMallMemberService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @作者 Administrator
 * @时间 2020-09-06 14:45
 * @版本 1.0
 */
@Controller
@RequestMapping(value = "/mall/member")
public class MallMemberController extends BaseController {

    @Autowired
    private MallMemberService mallMemberService;

    /**
     * 列表页面
     */
    @RequiresPermissions(value = "mall:member:list")
    @RequestMapping(value = "/list")
    public String list(){
        return "mall/member/memberList";
    }

    /**
     * 列表数据
     * @param memberName 会员名称
     * @param pageNo     页码
     * @param pageSize   每页数量
     */
    @RequiresPermissions(value = "mall:member:list")
    @RequestMapping(value = "/dataList")
    @ResponseBody
    public PageInfo<MallMember> dataList(
            @RequestParam(value = "memberName",required = false) String memberName,
            @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){
        return mallMemberService.memberList(new Page(pageNo,pageSize), memberName);
    }
}
